import { Injectable } from '@nestjs/common';
import { InjectModel } from '@nestjs/mongoose';
import { Model } from 'mongoose';
import { CreatePhotosTypeDto } from './dto/create-photosType.dto';
import { PhotosType, PhotosTypeDocument } from './schemas/photosType.schema';

@Injectable()
export class PhotosTypeService {
    constructor(@InjectModel(PhotosType.name) private photosTypeModel: Model<PhotosTypeDocument>) {}

    async create(input: CreatePhotosTypeDto) {
        const createdType = new this.photosTypeModel(input);
        return await createdType.save();
    }

    async findAll() {
        return await this.photosTypeModel.find().sort('-orderIndex').exec();
    }
}
